import operate from '@dfeidao/atom-nodejs/db/operate';

interface Message {
	_id: string;
	role_name: string;
	role_type_id: string;
	icon: string;
	productid: string;
}
export default async function atom(msg: Message, action_id: string, session_id: string) {
	const systemid = '12';
	const { exec, update } = operate(action_id, session_id, systemid);
	// const filter = {
	// 	_id: msg._id,
	// 	role_name: msg.role_name,
	// 	role_type_id: msg.role_type_id,
	// 	icon: msg.icon
	// };
	update('pub_role', { _id: msg._id }, {
		_id: msg._id,
		role_name: msg.role_name,
		role_type_id: msg.role_type_id,
		icon: msg.icon,
		productid: msg.productid
	});
	const res = await exec();
	if (res.code === 1) {
		return 'success';
	} else {
		return 'fail';
	}

}

